package com.chlitina.store.modules.cash.model;

import com.chlitina.store.modules.cash.entity.StoreCardAll;
import com.chlitina.store.modules.cash.model.recharge.CardAllRecharge;

/**
 * StoreAllCard 在本次完整消费中的总计支出 一个StoreCardAll 唯一对应一个 AllCardPayment
 * 
 * @author Songsong.xu
 * 
 */
public class AllCardPayment extends CardPayment {

	public AllCardPayment(StoreCardAll card, long id) {
		super(card, id);
		setNewCard(getCard().getId() == null);
		setRealMoney(card.getMoney());
		setCurrentMoney(card.getMoney());
	}

	public StoreCardAll getCard() {
		return (StoreCardAll) card;
	}

	public boolean addMoney(float addValue) {
		float temp = money + addValue;
		if (temp > getCard().getMoney()) {
			return false;
		}
		money += addValue;
		return true;
	}

	public void payMoney() {
		super.payMoney(getRealCost());
	}

	public void recharge(CardAllRecharge recharge) {
		System.err.println("-----------");
		System.err.println("Recharge:" + recharge.toString());
		System.err.println("Before Recharge:" + toString());
		float rechargeMoney = recharge.getRechargeMoney();
		setRechargeMoney(getRechargeMoney() + rechargeMoney);
		setCurrentMoney(getCurrentMoney() + rechargeMoney);
		System.err.println("End Recharge:" + toString());
	}

}
